home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gsgc.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.3 KB  |  100 lines

  1. /* Copyright (C) 1996, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gsgc.h,v 1.2 2000/09/19 19:00:29 lpd Exp $ */
  20. /* Library-level interface to garbage collector */
  21.  
  22. /*
  23.  * This API is not strictly at the library level, since it references
  24.  * gs_ref_memory_t and the 4 PostScript memory spaces; however, the former
  25.  * concept already leaks into the library's standard allocator, and the
  26.  * latter is relatively small and harmless.
  27.  */
  28.  
  29. #ifndef gsgc_INCLUDED
  30. #  define gsgc_INCLUDED
  31.  
  32. /*
  33.  * Define the VM space numbers, in increasing order of dynamism.  Pointers
  34.  * from a higher-numbered space to the same or a lower-numbered space are
  35.  * always allowed, but not vice versa.  Foreign space (the most static) is
  36.  * internal, the rest are visible to the programmer; the index of foreign
  37.  * space must be 0, so that we don't have to set any space bits in scalar
  38.  * refs (PostScript objects).
  39.  */
  40. typedef enum {
  41.     i_vm_foreign = 0,        /* must be 0 */
  42.     i_vm_system,
  43.     i_vm_global,
  44.     i_vm_local,
  45.     i_vm_max = i_vm_local
  46. } i_vm_space;
  47.  
  48. /* Define an array of allocators indexed by space. */
  49. #ifndef gs_ref_memory_DEFINED
  50. #  define gs_ref_memory_DEFINED
  51. typedef struct gs_ref_memory_s gs_ref_memory_t;
  52. #endif
  53. /*
  54.  * r_space_bits is only defined in PostScript interpreters, but if it is
  55.  * defined, we want to make sure it's 2.
  56.  */
  57. #ifdef r_space_bits
  58. #  if r_space_bits != 2
  59. Error_r_space_bits_is_not_2;
  60. #  endif
  61. #endif
  62. typedef struct vm_spaces_s vm_spaces;
  63. /*
  64.  * The garbage collection procedure is named vm_reclaim so as not to
  65.  * collide with the reclaim member of gs_dual_memory_t.
  66.  */
  67. #define vm_reclaim_proc(proc)\
  68.   void proc(P2(vm_spaces *pspaces, bool global))
  69. struct vm_spaces_s {
  70.     vm_reclaim_proc((*vm_reclaim));
  71.     union {
  72.     gs_ref_memory_t *indexed[4 /*1 << r_space_bits */ ];
  73.     struct _ssn {
  74.         gs_ref_memory_t *foreign;
  75.         gs_ref_memory_t *system;
  76.         gs_ref_memory_t *global;
  77.         gs_ref_memory_t *local;
  78.     } named;
  79.     } memories;
  80. };
  81.  
  82. /*
  83.  * By convention, the vm_spaces member of structures, and local variables
  84.  * of type vm_spaces, are named spaces.
  85.  */
  86. #define space_foreign spaces.memories.named.foreign
  87. #define space_system spaces.memories.named.system
  88. #define space_global spaces.memories.named.global
  89. #define space_local spaces.memories.named.local
  90. #define spaces_indexed spaces.memories.indexed
  91.  
  92. /*
  93.  * Define the top-level entry to the garbage collectors.
  94.  */
  95. #define GS_RECLAIM(pspaces, global) ((pspaces)->vm_reclaim(pspaces, global))
  96. /* Backward compatibility */
  97. #define gs_reclaim(pspaces, global) GS_RECLAIM(pspaces, global)
  98.  
  99. #endif /* gsgc_INCLUDED */
  100.